<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            background-color: black;
        }

        p {
            color: blueviolet;
            font-size: 50px;
            text-indent: 32px;
           
        }
        div{
            width: 500px;
            margin: 0 auto;
            margin-top: 30%;
        }
    </style>
</head>

<body>
    <div>
        <p></p>
    </div>
    <script>
        let text = "祝你天天开心!"
        let text2 = "把烦恼和悲伤通通丢掉"
        let p = document.querySelector("p")
        let flag = true
        function txt() {
            let t = ""
            if (flag) {
                for (let i = p.innerHTML.length; i < p.innerHTML.length + 1; i++) {
                    t = text.charAt(i)
                    if (i == text.length) {
                        p.innerHTML = ""
                        flag = false
                    }
                } p.innerHTML += t
            } else {
                for (let i = p.innerHTML.length; i < p.innerHTML.length + 1; i++) {
                    t = text2.charAt(i)
                    if (i == text2.length) {
                        p.innerHTML = ""
                        flag = true
                    }
                } p.innerHTML += t
            }
            console.log(text.length);
        }
        let a = setInterval(txt, 200)
        console.log(setInterval(txt, 200));
        clearInterval(a)
        
        // d763df9f84c543bd868115c8a02bac8b
        // qw6yvxtrrf.re.qweatherapi.com

     





    </script>
</body>

</html>